﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Automted_Bank_teller
{
    class Shuffle_Process :DatabaseConnection
    {

        public static float Money_after_shuffle;
        public static float Money;
        public static float Money_sent_to_client;
        public static string Client_id_Tranferee;

        public void selectData()
        {
            cmd.CommandText = "Select balance From Clients Where client_id='" + global_var.G_Client_ID + "'and pin_code='" + global_var.G_Client_PIN_Code + "'";
        }

        public void GetCurrentBalance()
        {

            SqlDataReader Selector = cmd.ExecuteReader();
            if (Selector.Read())
            {
                global_var.G_Current_Account_balance = float.Parse(Selector.GetValue(0).ToString());
                Money_after_shuffle = global_var.G_Current_Account_balance - Money;

            }
        }


        public void select_sent_to()
        {
            cmd.CommandText = "Select balance From Clients Where client_id='" + Client_id_Tranferee + "'";
        }


        public void GetCurrentBalance_sent_to_client()
        {

            SqlDataReader Selector = cmd.ExecuteReader();
            if (Selector.Read())
            {
                global_var.G_Current_Account_balance = float.Parse(Selector.GetValue(0).ToString());
                Money_sent_to_client = global_var.G_Current_Account_balance + Money;

            }
        }

        public void Upade_mainClient_Money()
        {
            cmd.CommandText = "Update Clients Set balance='" + Money_after_shuffle + "' Where client_id='" + global_var.G_Client_ID + "'and pin_code='" + global_var.G_Client_PIN_Code + "'";
        }

        public void Upadte_secondClientAcount()
        {
            cmd.CommandText = "Update Clients Set balance='" + Money_sent_to_client + "'where client_id='" + Client_id_Tranferee + "'";
        }

        public void ExecuteQuery()
        {
            cmd.ExecuteNonQuery();
        }




    }
}
